<?php
/**
 * Userdetails bearbeiten
 * @author Daniel Schmidt
 */
require_once("classes/User.php");
require_once ("classes/Error.php");
$user = new User();


   
 
include("template/header.inc.php")?>

<!-- Content	-->
<div class="grid_9" id="content">


<?php
if(!$user->ACL->hasPermission('access_site')){
	// Rechte ausreichend vorhanden zum anzeigen der Seite?
	header("location: ../rechtefehler.php");
}
if($_GET['action'] == "do") {
	$user->setUserData(	$_POST['username'],
						$_POST['email'],					
						$_POST['lieblingsverein'],
						$_POST['hobby'],
						$_POST['vorname'],
						$_POST['nachname']
	);
	$user->getUserData($user->userID);
	
} else {
?>
<h1>Profilbearbeitung von <?php echo $user->username; ?></h1> 
<form action="edit_user.php?action=do" method="post">
<table>
<tr>
			<td>Username:</td>
			<td><input type="text" name="username" value="<?php echo $user->username; ?>"/></td>
			</tr>
			<tr>
			<td>Email:</td>
			<td><input type="text" name="email" value="<?php echo $user->email; ?>"/></td>
			</tr>
<tr>
<td width="200px">Vorname: </td>
<td><input type="text" name="vorname" value="<?php if(isset($user->vorname)){ echo $user->vorname; } else { echo "Nicht angegeben"; } ?>"/></td>
</tr>
<tr>
<td width="200px">Nachname: </td>
<td><input type="text" name="nachname" value="<?php if(isset($user->nachname)){ echo $user->nachname; } else { echo "Nicht angegeben"; } ?>"/></td>
</tr>
<tr>
<td width="200px">Lieblingsverein: </td>
<td><input type="text" name="lieblingsverein" value="<?php if(isset($user->lieblingsverein)){ echo $user->lieblingsverein; } else { echo "Nicht angegeben"; } ?>"/></td>
</tr>
<tr>
<td width="200px">Hobbys: </td>
<td><input type="text" name="hobby" value="<?php if(isset($user->hobby)){ echo $user->hobby; } else { echo "Nicht angegeben"; } ?>"/></td>
</tr>
<tr>
<td width="200px">Dabei seit: </td>
<td><?php if(isset($user->ts_registered)){ echo date("d.m.Y", $user->ts_registered); } else { echo "Nicht angegeben"; } ?></td>
</tr>
<tr>
<td></td>
<td style="text-align: right"><input type="submit" name="submit" value="Daten ändern"/></td>
</table>
</form>
<?php
}
?>

			</div>
	<!-- Content	-->
	
<?php include ("template/sidebar.inc.php") ?>

<?php include("template/footer.inc.php")?>